
from django.utils import simplejson

from google.appengine.ext import db, search

class Bug(search.SearchableModel):
    name = db.StringProperty()
    source = db.TextProperty()
    version = db.StringProperty()
    fixed = db.BooleanProperty()
    submitted = db.DateTimeProperty()
    submitter = db.UserProperty()
    
    def to_dict(self):
        return {
            "key": unicode(self.key()),
            "name": unicode(self.name or "Bug %s" % self.key().id()),
            "source": unicode(self.source),
            "version": unicode(self.version),
            "fixed": unicode(self.fixed).lower(),
            "submitted": unicode(self.submitted),
            "submitter": unicode(self.submitter or "Anonymous")
        }